package com.mylibrary.service;

import com.mylibrary.dao.ReaderInfoDao;
import com.mylibrary.domain.ReaderInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Set;

@Service
public class RegisterServiceImpl implements RegisterService{
    @Resource
    private ReaderInfoDao readerInfoDao;
    @Override
    public int readerRegister(ReaderInfo readerInfo) {
      Set<String> s= readerInfoDao.selectAllUserName();

      if(s.contains(readerInfo.getUsername())){
          System.out.println("注册失败!!");
          return  -1;
      }else{

          int count= readerInfoDao.insertOne(readerInfo);
          return count;
      }
    }
}
